<?php
session_start();
include 'connection.php';
$email = $_POST['email'];
$password = md5($_POST['password']);

$result = callSP("getUserID('" . $email . "','" . $password . "');");

while ($rowResult = mysql_fetch_array($result)) {
	$userID = $rowResult['UserID'];
	$userEmail = $rowResult['Email'];
	$userRoleID = $rowResult['RoleID'];
}

if ($userID != null) {		
	$_SESSION["userID"] = $userID;
	$_SESSION["userEmail"] = $userEmail;
	$_SESSION["roleID"] = $userRoleID;
	$arr = array('success' => true, 'userID' => $userID, 'userEmail' => $userEmail, 'roleID' => $userRoleID);
	echo json_encode($arr);
} else {
	$arr = array('success' => false, 'message' => $password);
	echo json_encode($arr);
}
?>